package javaServlet;

import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * Created by fin on 2017/5/29.
 */
@WebServlet("/validateCodeCheck")
public class ValidateCodeCheck extends javax.servlet.http.HttpServlet {

    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException {
        request.setCharacterEncoding("utf-8");
        // 获取存放在session中的验证码
        String code = (String) request.getSession().getAttribute("code");
        // 获取页面提交的验证码
        String inputCode = request.getParameter("code");
        if(inputCode.equals(code)){
            response.sendRedirect("success.jsp");
        }else{
            response.sendRedirect("fail.jsp");
        }
    }
}
